<?php

namespace app\api\controller;

use app\api\model\BannerModel;
use app\api\validate\IndexValidate;
use app\BaseController;

class Banner extends BaseController
{
    /**
     * 显示资轮播图列表
     */
    public function index()
    {
        $bannerType = input();
        // 验证参数
        $validate = new IndexValidate();
        $result = $validate->scene('banner')->check($bannerType);
        if ($result !== true) {
            $this->error($validate->getError());
        }
        $model = BannerModel::field('id,image')
            ->where('status', 1)
            ->where('nav_id', $bannerType['nav_id'])
            ->select()->toArray();
        if ($model) {
            $this->success('获取成功', $model);
        } else {
            $this->error('获取失败');
        }
    }

}